perm filename FOO.LSP[F82,JMC] blob sn#692378 filedate 1982-12-18 generic text, type C, neo UTF8
COMMENT āŠ—   VALID 00002 PAGES
C REC  PAGE   DESCRIPTION
C00001 00001
C00002 00002	for checking out students' answers on CS206 final
C00003 ENDMK
CāŠ—;
;;for checking out students' answers on CS206 final
;;; Martin Abadi compactify

(defun compactify (x y) (if (atom x) x
			    (subsptrs (cdr x) y (subsptrs (car x) y x))))

(defun subsptrs (x y z)
       (subsptrs1 (or (occurrence x y) (compactify x y))
		  z))

(defun subsptrs1 (s z)
       (if (equal s z) s
	   (if (atom z) z
	       (cons (subsptrs1 s (car z)) (subsptrs1 s (cdr z))))))

(defun occurrence (x y)
       (if (equal x y) y
	   (if (atom y) nil
	       (or (occurrence x (car y)) (occurrence x (cdr y))))))